// The abstract interface for token object.
// No extra specifiers required.
#ifndef _ITOKEN
#define _ITOKEN

#include <string>
#include <vector>
#include "config.hpp"

struct itoken
{
	virtual std::string const read(unsigned short* _index_ptr=(unsigned short*)0) = 0;
	virtual std::string const read(std::vector<unsigned short> const& _substring_indices) =0;

	virtual void write(const char* _token='\0') =0;
	virtual void write(const char* _filename, bool _one_character_per_page) = 0;
	virtual void write(const char* _filename, std::vector<unsigned short> const& _substring_indices, bool _one_character_per_page=true) = 0;
	
	virtual config const get_config() const =0;
	virtual std::string const get_keypad_config_filename() const = 0;

};

#ifndef WIN32
#define TOKEN_API
#else
#ifdef TOKEN_EXPORTS
#define TOKEN_API __declspec(dllexport)
#else 
#define TOKEN_API __declspec(dllimport)
#endif
#endif

// Factory function that creates instances of the token object
extern "C" class TOKEN_API libtoken
{
public:
	libtoken(const char* _filename);
	~libtoken();

	itoken* getToken();

private:	
	itoken* _tk;
};


extern "C" TOKEN_API std::ostream& operator << (std::ostream& ost, itoken& c);

#endif
